package com.googlecode.wmlynar.javadoctc.reportgen;

import com.googlecode.wmlynar.javadoctc.domain.JavaDocClass;
import com.googlecode.wmlynar.javadoctc.domain.JavaDocClassPool;
import com.googlecode.wmlynar.javadoctc.domain.JavaDocMethod;

public class ReportGenerator {

	public String generateListClasses(JavaDocClassPool classes) {
		StringBuilder sb = new StringBuilder();
		
		sb.append("<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>");
		sb.append("<html><body>");
		sb.append("<table border=\"1\">");
		
		// title
		sb.append("<tr>");
		sb.append("<td>Class</td>");
		sb.append("<td>Method</td>");
		sb.append("<td>Comment</td>");
		sb.append("</tr>");
		
		for(JavaDocClass c : classes.getClassList()) {
			sb.append("<tr>");
			sb.append("<td colspan=\"3\">"+c.getName()+"</td>");
			sb.append("</tr>");
			
			for(JavaDocMethod m:c.getMethodList()) {
				sb.append("<tr>");
				sb.append("<td> </td>");
				sb.append("<td colspan=\"2\">"+m.getName()+"</td>");
				sb.append("</tr>");
				sb.append("<tr>");
				sb.append("<td> </td>");
				sb.append("<td> </td>");
				if(m.getJavadoc()==null) {
					sb.append("<td>MISSING JAVADOC</td>");
				} else {
					sb.append("<td>"+m.getJavadoc()+"</td>");
				}
				sb.append("</tr>");
				//  VALIGN=\"top\"
			}
		}
		
		sb.append("</table>");
		sb.append("</body></html>");
		
		return sb.toString();
	}
	
}
